package  
{
	import Levels.Level;
	/**
	 * ...
	 * @author Thiago Gomes da Silva
	 */
	public class EnemyManager 
	{
		private var enemies:Array;
		private var level:Level;
		private var frames:int;
		private var ajust:int;
		private var enemyCountMeter:int;
		
		public function EnemyManager(level:Level) 
		{
			this.level = level;
			enemies = new Array();
			this.ajust = 20;
		}
		
		public function createEnemy(speed:Number)
		{
			var enemy:Enemy = new Enemy(15, level);
			
			enemy.x = (Math.random() * (Main.getInstance().stage.stageWidth - enemy.width));
			enemy.y = - (enemy.height + ajust);
			
			level.addChild(enemy);
			this.enemies.push(enemy);
		}
		
		public function getEnemies():Array
		{
			return enemies;
		}
		
		public function getEnemyCount():int
		{
			return enemyCountMeter
		}
		
		public function setEnemyCount(e:int):void
		{
			this.enemyCountMeter = e;
			
		}
		
		public function update()
		{
			for (var k:int = 0; k < enemies.length; k++)
			{
				enemies[k].update();
			}
			if(frames >= enemyCountMeter)
			{
				frames = 0;
				this.createEnemy(1);
			}
			else
			{
				frames++;
			}
			
		}
	}

}